%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/archived-forum-inherited-messages.defer-4"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 77, 78, 11, 13, 28<br />2: PgSelect[8]<br />3: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 11, 28<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 11, 28<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 17, 19, 25<br />2: PgSelect[20]<br />3: Connection[24]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 24, 11, 19, 25, 28, 20<br /><br />ROOT Connection{2}ᐸ20ᐳ[24]<br />1: ConnectionItems[29], PgSelect[35]<br />ᐳ: 34, 43, 44, 46, 45, 47, 48, 49<br />2: PgSelectRows[37]<br />ᐳ: 36, 38, 39"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 46, 11<br /><br />ROOT __Item{6}ᐸ29ᐳ[40]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 41, 11<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[41]"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 42, 41, 11, 51<br /><br />ROOT Edge{6}[42]"):::bucket
    Bucket9("Bucket 9 (defer)<br />Deps: 41, 11<br /><br />1: <br />ᐳ: 53, 54<br />2: PgSelect[55]<br />3: PgSelectRows[60]<br />ᐳ: First[59], PgSelectSingle[61]"):::bucket
    Bucket10("Bucket 10 (nullableBoundary)<br />Deps: 41, 11<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[41]<br />1: <br />ᐳ: 62, 63<br />2: PgSelect[64]<br />3: PgSelectRows[69]<br />ᐳ: First[68], PgSelectSingle[70]"):::bucket
    Bucket11("Bucket 11 (nullableBoundary)<br />Deps: 61<br /><br />ROOT PgSelectSingle{9}ᐸusersᐳ[61]"):::bucket
    Bucket12("Bucket 12 (nullableBoundary)<br />Deps: 70<br /><br />ROOT PgSelectSingle{10}ᐸusersᐳ[70]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket6
    Bucket6 --> Bucket7 & Bucket8
    Bucket7 --> Bucket9
    Bucket8 --> Bucket10
    Bucket9 --> Bucket11
    Bucket10 --> Bucket12

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'EXCLUSIVELY' ]ᐳ[77]"}}:::plan
    Lambda13 --> PgSelect8
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 5"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    Lambda28{{"Lambda[28∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />Dependents: 2<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[78]"}}:::plan
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgSelect20[["PgSelect[20∈2]<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[11]<br />- Lambda[28]"]]:::plan
    PgClassExpression19{{"PgClassExpression[19∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgClassExpression25{{"PgClassExpression[25∈2]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
    PgClassExpression19 & PgClassExpression25 --> PgSelect20
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgSelectSingle16 --> PgClassExpression19
    Connection24[["Connection[24∈2]<br />ᐸ20ᐳ"]]:::plan
    PgSelect20 --> Connection24
    PgSelectSingle16 --> PgClassExpression25
    PgSelect35[["PgSelect[35∈3]<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[11]<br />- Lambda[28]"]]:::plan
    PgClassExpression19 & PgClassExpression25 --> PgSelect35
    PgCursor47{{"PgCursor[47∈3]"}}:::plan
    First45{{"First[45∈3]"}}:::plan
    Access46{{"Access[46∈3]<br />ᐸ20.cursorDetailsᐳ"}}:::plan
    First45 & Access46 --> PgCursor47
    PgCursor49{{"PgCursor[49∈3]"}}:::plan
    Last48{{"Last[48∈3]"}}:::plan
    Last48 & Access46 --> PgCursor49
    ConnectionItems29[["ConnectionItems[29∈3]"]]:::plan
    Connection24 --> ConnectionItems29
    PageInfo34{{"PageInfo[34∈3]"}}:::plan
    Connection24 --> PageInfo34
    First36{{"First[36∈3]"}}:::plan
    PgSelectRows37[["PgSelectRows[37∈3]"]]:::plan
    PgSelectRows37 --> First36
    PgSelect35 --> PgSelectRows37
    PgSelectSingle38{{"PgSelectSingle[38∈3]<br />ᐸmessagesᐳ"}}:::plan
    First36 --> PgSelectSingle38
    PgClassExpression39{{"PgClassExpression[39∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle38 --> PgClassExpression39
    Access43{{"Access[43∈3]<br />ᐸ24.hasNextPageᐳ"}}:::plan
    PageInfo34 o--o Access43
    Access44{{"Access[44∈3]<br />ᐸ24.hasPreviousPageᐳ"}}:::plan
    Access43 o--o Access44
    ConnectionItems29 --> First45
    PgSelect20 --> Access46
    ConnectionItems29 --> Last48
    Edge42{{"Edge[42∈6]"}}:::plan
    __Item40[/"__Item[40∈6]<br />ᐸ29ᐳ"\]:::itemplan
    PgCursor51{{"PgCursor[51∈6]"}}:::plan
    __Item40 & PgCursor51 --> Edge42
    __Item40 & Access46 --> PgCursor51
    ConnectionItems29 ==> __Item40
    PgSelectSingle41{{"PgSelectSingle[41∈6]<br />ᐸmessagesᐳ"}}:::plan
    __Item40 --> PgSelectSingle41
    PgSelect55[["PgSelect[55∈9]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression54{{"PgClassExpression[54∈9]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression54 --> PgSelect55
    PgClassExpression53{{"PgClassExpression[53∈9]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle41 --> PgClassExpression53
    PgSelectSingle41 --> PgClassExpression54
    First59{{"First[59∈9]"}}:::plan
    PgSelectRows60[["PgSelectRows[60∈9]"]]:::plan
    PgSelectRows60 --> First59
    PgSelect55 --> PgSelectRows60
    PgSelectSingle61{{"PgSelectSingle[61∈9]<br />ᐸusersᐳ"}}:::plan
    First59 --> PgSelectSingle61
    PgSelect64[["PgSelect[64∈10]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression63{{"PgClassExpression[63∈10]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression63 --> PgSelect64
    PgClassExpression62{{"PgClassExpression[62∈10]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgClassExpression53 o--o PgClassExpression62
    PgSelectSingle41 --> PgClassExpression63
    First68{{"First[68∈10]"}}:::plan
    PgSelectRows69[["PgSelectRows[69∈10]"]]:::plan
    PgSelectRows69 --> First68
    PgSelect64 --> PgSelectRows69
    PgSelectSingle70{{"PgSelectSingle[70∈10]<br />ᐸusersᐳ"}}:::plan
    First68 --> PgSelectSingle70
    PgClassExpression71{{"PgClassExpression[71∈11]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle61 --> PgClassExpression71
    PgClassExpression72{{"PgClassExpression[72∈11]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression71 o--o PgClassExpression72
    PgClassExpression73{{"PgClassExpression[73∈12]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle70 --> PgClassExpression73
    PgClassExpression74{{"PgClassExpression[74∈12]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression73 o--o PgClassExpression74

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,Lambda28 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression17,PgClassExpression19,PgSelect20,Connection24,PgClassExpression25 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,ConnectionItems29,PageInfo34,PgSelect35,First36,PgSelectRows37,PgSelectSingle38,PgClassExpression39,Access43,Access44,First45,Access46,PgCursor47,Last48,PgCursor49 bucket3
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item40,PgSelectSingle41,Edge42,PgCursor51 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression53,PgClassExpression54,PgSelect55,First59,PgSelectRows60,PgSelectSingle61 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,PgClassExpression62,PgClassExpression63,PgSelect64,First68,PgSelectRows69,PgSelectSingle70 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11,PgClassExpression71,PgClassExpression72 bucket11
    classDef bucket12 stroke:#4169e1
    class Bucket12,PgClassExpression73,PgClassExpression74 bucket12

